package pers.qianyu.month_202101.date_20210125;

/**
 * 32. 调整数组顺序使奇数位于偶数前面
 * https://www.acwing.com/problem/content/30/
 *
 * @author mizzle rain
 * @date 2021-01-25 17:15
 */
public class ReOrderArray {
    public void reOrderArray(int[] array) {
        int len = array.length;
        if (len == 0) return;
        int left = 0, right = len - 1;
        while (left < right) {
            while (left < right && (array[left] & 1) == 1) left++;
            while (left < right && (array[right] & 1) == 0) right--;
            int temp = array[left];
            array[left] = array[right];
            array[right] = temp;
        }
    }
}
